﻿using CDSysLDManageProject.BYDTableAdapters;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CDSysLDManageProject
{
    public partial class FormSearchHtTask : Form
    {

        public FormSearchHtTask()
        {
            InitializeComponent();
            dgvCurrentTask.AutoGenerateColumns = false;
        }
        ht_LDTaskListTableAdapter httask = new ht_LDTaskListTableAdapter();
        DataTable task = new DataTable();
        private void button1_Click(object sender, EventArgs e)
        {
            string trayno = tbxtrayno.Text;

            refreshQuery(trayno);
        }

        public void refreshQuery(string trayno)
        {
            if (string.IsNullOrEmpty(trayno))
            {
                if (checkboxin.Checked == true && checkboxout.Checked == true)
                {
                    task = httask.GetTaskList();
                    dgvCurrentTask.DataSource = task;
                }
                else if (checkboxin.Checked)
                {
                    task = httask.GetInTaskList();
                    dgvCurrentTask.DataSource = task;
                }
                else if (checkboxout.Checked)
                {
                    task = httask.GetOutTaskList();
                    dgvCurrentTask.DataSource = task;
                }
                else
                {
                    task = httask.GetTaskList();
                    dgvCurrentTask.DataSource = task;
                }

            }
            else
            {
                trayno = trayno + "%";
                task = httask.GetTaskByTrayNo(trayno);
                dgvCurrentTask.DataSource = task;
            }

        }

    }
}
